package auto.generalcode.easyhome.tool;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import org.springframework.web.multipart.MultipartFile;

public class UploadUtils {
	
	private static String basePath = "C:\\fileupload";
	//private static String basePath = "/u01/resource";
	
	private static final String TEMP_PATH = "/temp";
	
	private static String tempPath = basePath + TEMP_PATH;
   
	public static File upload(MultipartFile file) throws Exception {
		UploadUtils.Method();
		File basefile = new File(tempPath);
		if (basefile.exists()) {
			basefile.mkdirs();
		}
		File tempFile = new File(tempPath + new Date().getTime() + ".xlsx");
		file.transferTo(tempFile);
		return tempFile;
	}
	
	public static void Method() {
		System.out.println("================================================");
		String path=UploadUtils.class.getResource("/").getPath();
		System.out.println(path);
		System.out.println("================================================");
	}
}
